// 可关闭的消息提示
<template>
<p>可以添加关闭按钮。</p>
<p>默认的 Message 是不可以被人工关闭的。 如果你需要手动关闭功能，你可以把 <code>showClose</code> 设置为 true 此外，和 Notification 一样，Message 拥有可控的 <code>duration</code>， 默认的关闭时间为 3000 毫秒，当把这个属性的值设置为<code>0</code>便表示该消息不会被自动关闭。</p>
  <el-button :plain="true" @click="open1">Message</el-button>
  <el-button :plain="true" @click="open2">Success</el-button>
  <el-button :plain="true" @click="open3">Warning</el-button>
  <el-button :plain="true" @click="open4">Error</el-button>
</template>

<script lang="ts" setup>
import { ElMessage } from 'element-plus'

const open1 = () => {
  ElMessage({
    showClose: true,
    message: 'This is a message.',
  })
}
const open2 = () => {
  ElMessage({
    showClose: true,
    message: 'Congrats, this is a success message.',
    type: 'success',
  })
}
const open3 = () => {
  ElMessage({
    showClose: true,
    message: 'Warning, this is a warning message.',
    type: 'warning',
  })
}
const open4 = () => {
  ElMessage({
    showClose: true,
    message: 'Oops, this is a error message.',
    type: 'error',
  })
}
</script>

<style scoped>
@import '../../assets/elementPlusDemo.css'
</style>